package fractales.algo;

import java.awt.Graphics2D;
import java.awt.geom.Point2D;

import fractales.ui.FractaleUI;


public class CourbeDeKochQuadratique2 extends Fractale
{
	private static final double _90_DEGRES = Math.PI/2;
	
	protected void recurse(Graphics2D g, double x1, double y1, double x2, double y2, double length, double angle, int iteration) {
		
		double newLength = length / 4.0;
		
		Point2D p1 = drawLine(g, x1, y1, newLength, angle, iteration);
		Point2D p2 = drawLine(g, p1.getX(), p1.getY(), newLength, angle+_90_DEGRES, iteration);
		Point2D p3 = drawLine(g, p2.getX(), p2.getY(), newLength, angle, iteration);
		Point2D p4 = drawLine(g, p3.getX(), p3.getY(), newLength, angle-_90_DEGRES, iteration);
		Point2D p5 = drawLine(g, p4.getX(), p4.getY(), newLength, angle-_90_DEGRES, iteration);
		Point2D p6 = drawLine(g, p5.getX(), p5.getY(), newLength, angle, iteration);
		Point2D p7 = drawLine(g, p6.getX(), p6.getY(), newLength, angle+_90_DEGRES, iteration);
		drawLine(g, p7.getX(), p7.getY(), x2, y2, newLength, angle, iteration);
	}

	public static void main (String[] args)
	{
		CourbeDeKochQuadratique2 p = new CourbeDeKochQuadratique2();
		FractaleUI.display(p);
	}
}
